package com.wh.custom.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.wh.custom.pojo.CustomCustomertype;
import com.wh.custom.dao.CustomTypeMapper;
import com.wh.custom.service.ICustomCustomertypeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wh.custom.dto.CustomCustomertypeQueryDto;

/**
 * 业务实现类
 */
@Service
public class CustomCustomertypeServiceImpl extends ServiceImpl<CustomTypeMapper, CustomCustomertype> implements ICustomCustomertypeService {

    @Autowired
    private CustomTypeMapper customTypeMapper;

    @Override
    public IPage<CustomCustomertype> findByPage(CustomCustomertypeQueryDto customCustomertypeQueryDto){
        //1.创建查询条件
        QueryWrapper<CustomCustomertype> qw = new QueryWrapper<>();
        qw.like("customer_type",customCustomertypeQueryDto.getKeyword());
        //qw.or();
        //qw.like("xxx",customCustomertypeQueryDto.getXxx());
        //2.组件分页数据
        IPage<CustomCustomertype> page = new Page<>(customCustomertypeQueryDto.getCurrentPage(), customCustomertypeQueryDto.getPageSize());
        page.setRecords(customTypeMapper.findByPage(page,qw));
        page.setTotal(customTypeMapper.selectCount(qw));
        //3.返回
        System.err.println(page);
        return page;
    }

}
